
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently

#pragma once

#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers
#endif

#include "targetver.h"

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit

// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <assert.h>

#include <afxdisp.h>        // MFC Automation classes

// JPNSMTP
#define CPJNSMTP_NOSSL 1
#include <WinDNS.h>
#include <wincrypt.h>
#include <atlenc.h>


// Here, minimal DB support is requested.  No view is chosen.

#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h>           // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>             // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

//#include <afxdb.h>        // ODBC
#include <atlbase.h>		// CRegKey
#include <atlcoll.h>		// CAtlMap
#include <strsafe.h>		// StringCchCopy

// for webbrowser control
#include <ExDispid.h>
#include <afxdhtml.h>
#include <afxinet.h>
#include <Wininet.h>
#include <mshtmcid.h>
#include <afxhtml.h>

#include <afxcontrolbars.h>     // MFC support for ribbons and control bars

// for FTP
#include <afxmt.h>


// bounds for help link menu items
#define HLM_LRANGE 0xe00
#define HLM_URANGE 0xfff

// structures
struct FILE_PAIR
{
	CString szFileTo;
	CString szFileFrom;
};

typedef CArray<FILE_PAIR> CFilePair;

struct QUEUE_FILE_INFO
{
	INT m_nStatus;
	LONG m_nTries;
	INT m_nStepID;
	TCHAR m_szFileSource[MAX_PATH];
	TCHAR m_szFileDestination[MAX_PATH];
	TCHAR m_szEmailTo[MAX_PATH];
	TCHAR m_szEmailBody[4096];	
};

struct STAFF_LOOKUP
{
	LONG nStaffID;
	INT nStaffLevel;
	CString szStaffName;
	CString szStaffEmail;
	CString szStaffPhone;
	LONG nLibraryID;
};

struct LIBRARY_LOOKUP
{
	LONG nID;
	CString	szDescription;
	CString	szName;
	CString	szPhone;
	CString	szAddress;
	CString	szEmail;
	CString szSubject;
	INT nType;
	INT nUserListed;
	CString szInformation;
	BOOL bDiverted;
};

struct COLLECTION_LOOKUP
{
	LONG nID;
	CString	szDescription;
	CString	szName;
	INT nUserListed;
	INT nElectronic;
	CString szIconFile;
	CString szPrintNotice;
	// internal variables
	INT nIcon;
};

struct ILL_LOOKUP
{
	LONG nID;
	CString	szDescription;
	CString szExplanation;
	CString szMessageSubject;
	INT nUserListed;
};

struct PRIORITY_LOOKUP
{
	LONG nID;
	CString szDescription;
	CString szPrintNotice;
	CString szIconFile;;
	double dServiceFee;
	LONG nInHours;
	UINT nUserListed;
	CString szTextColor;
	CString szTextColorOld;
	CString szBackGroundColor;
	CString szBackGroundColorOld;
	// internal variables
	INT nIcon;
};

struct METHOD_LOOKUP
{
	LONG nID;
	CString szDescription;
	CString szPrintNotice;
	CString szIconFile;
	double dServiceFee;
	INT nUserListed;
	INT nElectronic;
	CString szMessageFile;
	CString szMessageSubject;
	CString szInformation;
	// internal variables
	INT nIcon;
};

struct STATUS_LOOKUP
{
	LONG nID;
	CString	szDescription;
	CString szExplanation;
	CString szSubject;
	CString	szMessage;
	CString	szCode;
	CString	szIconFile;
	CString szNotify;
	INT nSendILL;
	INT nComplete;
	CString szInformation;
	CString szMessageFile;
	CString szMessageFileExt;
	// internal variables
	INT nIcon;
};

struct USER_TYPE_LOOKUP
{
	LONG nID;
	CString	szDescription;
	INT nExternal;
};

struct USER_LOOKUP
{
	LONG nID;
	CString	szName;
	CString	szEmail;
	CString	szCompany;
	CString szAddress1;
	CString szAddress2;
	CString	szPhone;
	CString	szFax;
};

struct REQUEST_HISTORY
{
	LONGLONG m_id;
	LONG m_request_id;
	LONG m_user_id;
	COleDateTime m_date_in;
	LONG m_status_id;
	CString m_description;
};

struct REQUEST_LINK
{
	LONG m_id;
	LONG m_staff_id;
	COleDateTime m_date_in;
	CString m_uid;
	CString m_title;
	CString m_source;
	CString m_link;
	CString m_notes;
	INT m_material;
};

struct SOURCE_LINK
{
	LONG m_id;
	LONG m_staff_id;
	COleDateTime m_date_in;
	CString m_title;
	CString m_link;
	CString m_notes;
	INT m_material;
};

struct USER_HISTORY
{
	LONGLONG m_id;
	LONG m_user_id;
	COleDateTime m_date_in;
	CString m_description;
};

struct STAFF_SET
{
	LONG m_id;
	LONG m_level;
	CString m_name;
	CString m_pwd;
	CString m_email;
	CString m_phone;
	COleDateTime m_date_login;
	LONG m_library_id;
	INT m_show_triage;
	INT m_show_library_view;
	INT m_show_my_view;
	INT m_show_process_view;
	INT m_show_current_view;
	INT m_show_completed_view;
	INT m_show_hold_view;
	INT m_show_highlights;
	INT m_show_duplicates;
	INT m_sort_ascending;
	INT m_print_full_request;
	INT m_bold_email_print;
	INT m_enable_thumbnail;
	INT m_completed_days;
	INT m_use_print_template;
	LONG m_print_per_page;
	INT m_default_collection;
	INT m_default_ill_library;
};

struct USER_SET
{
	LONG m_id;
	INT	m_level;
	CString m_lan_id;
	CString	m_name;
	CString	m_pwd;
	CString	m_email;
	CString	m_company;
	CString	m_phone;
	CString	m_fax;
	CString m_shipto;
	CString	m_address1;
	CString	m_address2;
	CString m_city;
	CString	m_state;
	CString	m_zipcode;
	CString	m_country;
	CString m_billto;
	CString	m_billaddress1;
	CString	m_billaddress2;
	CString	m_billcity;
	CString	m_billstate;
	CString	m_billzipcode;
	CString	m_billcountry;
	CString	m_altemail1;
	CString	m_altemail2;
	CString	m_altemail3;
	CString	m_altemail4;
	CString	m_altemail5;
	INT	m_library_id;
	COleDateTime m_date_join;
	COleDateTime m_date_login;
	INT	m_taxable;
	DOUBLE	m_fee_max;
	INT	m_activation_code;
	INT	m_activated;
	INT	m_notify;
	INT m_type;
	INT m_method_id;
	INT m_referrals;
	INT m_copyright;
	CString m_account_number;
	CString m_shipping_number;
	INT m_external;
	CString	m_notes;
	LONG m_external_id;
};

struct REQUEST_SET
{
	// request
	LONG m_id;
	LONG m_staff_id;
	LONG m_user_id;
	COleDateTime m_date_in;
	COleDateTime m_date_hold;
	COleDateTime m_date_out;
	INT	m_status_id;
	INT	m_collection_id;
	INT	m_library_id;
	INT	m_atlibrary;
	LONG m_verified_id;
	INT	m_step_id;
	CString	m_request;
	CString	m_instructions;
	CString	m_information;
	CString	m_notes;
	CString	m_uid;
	CString	m_title;
	CString	m_source;
	INT	m_priority_id;
	INT	m_method_id;
	INT	m_ill_id;
	CString	m_file;
	INT	m_viewed;
	INT	m_redirected;
	INT	m_touched;
	INT	m_webcheck;
	INT	m_deleted;
	INT	m_invoiced;
	INT	m_type;
	INT	m_level;
	CString m_project;
	INT	m_taxable;
	INT	m_overdue;
	INT	m_copyright;
	INT	m_canceled;
	INT	m_resubmitted;
	INT	m_finalized;
	INT m_referrals;
	INT m_manual;
	INT m_material;
	DOUBLE m_fee_copyright;
	DOUBLE m_fee_service;
	DOUBLE m_fee_misc;
	LONG m_external_id;
	CString m_location;
	CString m_link;
	INT m_retain;
};

struct REQUEST_DISPLAY_SET
{
	//enum COLUMN{ COL_SCHEDULE, COL_DELIVERY, COL_ITEM, COL_DATE, COL_EMAIL, COL_LOCATION, COL_UID, COL_DETAIL, COL_PROJECT, COL_SOURCE, COL_WORKER, COL_LIBRARY, COL_STATUS, COL_STEP };

	// request
	LONG m_id;
	LONG m_staff_id;
	LONG m_user_id;
	COleDateTime m_date_in;
	COleDateTime m_date_hold;
	COleDateTime m_date_out;
	INT m_status_id;
	INT m_library_id;
	INT	m_collection_id;
	INT	m_atlibrary;
	INT m_step_id;
	CString m_request;
	CString m_uid;
	CString m_source;
	INT m_priority_id;
	INT m_method_id;
	INT m_touched;
	INT m_webcheck;
	INT	m_invoiced;
	CString m_project;
	LONG m_external_id;
	CString m_location;
	CString m_link;
	INT m_retain;

	// user
	CString	m_users_email;
	CString m_users_lan_id;
	CString	m_users_company;
	CString	m_users_address1;

	// source
	CString m_request_link;
	CString m_source_link;
	CString m_source_notes;
	INT m_source_material;
};

struct ARTICLE_REQUEST
{
	// request
	LONG m_id;
	LONG m_staff_id;
	LONG m_user_id;
	COleDateTime m_date_in;
	COleDateTime m_date_hold;
	COleDateTime m_date_out;
	INT	m_status_id;
	INT	m_collection_id;
	INT	m_library_id;
	INT	m_atlibrary;
	LONG m_verified_id;
	INT	m_step_id;
	CString	m_request;
	CString	m_instructions;
	CString	m_information;
	CString	m_notes;
	CString	m_uid;
	CString	m_title;
	CString	m_source;
	INT	m_priority_id;
	INT	m_method_id;
	INT	m_ill_id;
	CString	m_file;
	INT	m_viewed;
	INT	m_redirected;
	INT	m_touched;
	INT	m_webcheck;
	INT	m_deleted;
	INT	m_invoiced;
	INT	m_type;
	INT	m_level;
	CString m_project;
	INT	m_taxable;
	INT	m_overdue;
	INT	m_copyright;
	INT	m_canceled;
	INT	m_resubmitted;
	INT	m_finalized;
	INT m_referrals;
	INT m_manual;
	INT m_material;
	DOUBLE	m_fee_copyright;
	DOUBLE	m_fee_service;
	DOUBLE	m_fee_misc;
	LONG m_external_id;
	CString m_location;
	CString m_link;
	BOOL m_retain;

	// users
	LONG m_users_id;
	INT	m_users_level;
	CString	m_users_name;
	CString	m_users_pwd;
	CString	m_users_email;
	CString m_users_lan_id;
	CString	m_users_company;
	CString	m_users_phone;
	CString	m_users_fax;
	CString m_users_shipto;
	CString	m_users_address1;
	CString	m_users_address2;
	CString	m_users_city;
	CString	m_users_state;
	CString	m_users_zipcode;
	CString	m_users_country;
	CString m_users_billto;
	CString	m_users_billaddress1;
	CString	m_users_billaddress2;
	CString	m_users_billcity;
	CString	m_users_billstate;
	CString	m_users_billzipcode;
	CString	m_users_billcountry;
	CString	m_users_altemail1;
	CString	m_users_altemail2;
	CString	m_users_altemail3;
	CString	m_users_altemail4;
	CString	m_users_altemail5;
	INT	m_users_library_id;
	COleDateTime m_users_date_join;
	COleDateTime m_users_date_login;
	INT m_users_taxable;
	DOUBLE m_users_fee_max;
	INT m_users_activation_code;
	INT m_users_activated;
	INT m_users_notify;
	INT m_users_type;
	INT m_users_method_id;
	INT m_users_referrals;
	INT m_users_copyright;
	CString m_users_account_number;
	CString m_users_shipping_number;
	INT m_users_external;
	CString	m_users_notes;
	LONG m_users_external_id;

	// source
	CString m_source_notes;
};

struct EXTERNAL_ILL_SET
{
	LONG m_id;
	CString m_email;
	CString m_company;
	LONG m_sent;
	COleDateTime m_date_join;
	COleDateTime m_date_out;
};

struct EXTERNAL_ILL_HISTORY
{
	LONG m_staff_id;
	LONG m_user_id;
	COleDateTime m_date_out;
	CString m_description;
	CString m_link;
	CString m_staff_name;
	CString m_user_email;
};

struct LDAP_USER_INFO
{
	CString szName;
	CString szFirstName;
	CString szLastName;
	CString szFullName;
	CString szEmail;
	CString szLANID;
	CString szPhone;
	CString szAddress;
	CString szPager;
};

struct LDAP_STAFF_INFO
{
	CString szEmail;
	CString szLANID;
	CString szPhone;
};

typedef CAtlMap<LONGLONG, REQUEST_DISPLAY_SET> RequestMap;

// decimal defines

#define DATABASE_VERSION 21059
#define ID_TIMER	3001

#define EXTERNAL_ILL_MENU_ITEM 3
#define ADMIN_MENU_ITEM 5
#define HELP_MENU_ITEM 6

#define MAX_SQL_MEMO_LENGTH 16384
#define DETAIL_LENGTH 50
#define TICKER_MULTIPLIER 5
#define TICKER_MULTIPLIER_LONG 100
#define PRINT_LINE_LIMIT 8

#define ID_TRG 0

#define ICON_LIST_SIZE 14

// bitwise defines

#define ID_NORMAL_LIBRARY 0x00
#define ID_PROBLEM_LIBRARY 0x01
#define ID_INTERNAL_ILL_LIBRARY 0x02
#define ID_EXTERNAL_ILL_LIBRARY 0x04

#define ID_LIST_ON_REQUEST 0x01
#define ID_LIST_ON_RESUBMIT 0x02

#define ID_CHECKED_ONLINE 0x01
#define ID_CHECKED_ONLINE_LINK 0x100


// enums

enum TAB{ TAB_LIBRARY, TAB_HOLD, TAB_WORKER, TAB_PROCESS, TAB_ARTICLES, TAB_COMPLETE, TAB_FIND };
enum COLUMN{ COL_SCHEDULE, COL_DELIVERY, COL_COLLECTION, COL_ITEM, COL_DATE, COL_DATE_HOLD, COL_EMAIL, COL_LOCATION, COL_DETAIL, COL_PROJECT, COL_UID, COL_SOURCE, COL_WORKER, COL_LIBRARY, COL_STATUS };

enum ICON{ ICON_NONE=-1, ICON_BLANK=0, ICON_PROBLEM, ICON_TRIAGE, ICON_AT_LIBRARY, ICON_INVOICED, ICON_LENDING_ILL, ICON_BORROWING_ILL, ICON_TIME, ICON_TIME_TRIAGE, ICON_WEB_CHECK, 
			ICON_WEB_LINK, ICON_WEB_MAYBE, ICON_WEB_FREE, ICON_WEB_NOT_FREE, ICON_RESUBMITTED, ICON_NOT_AVAILABLE, ICON_EXTERNAL, ICON_DIVERT };

enum STEP{ STEP_COLLECTION = 0, STEP_ILL };

enum STATUS{ STATUS_ID_NEW = 0, STATUS_ID_PENDING, STATUS_ID_IN_PROCESS, STATUS_OFFSET_HOLD = 100, STATUS_OFFSET_ILL = 200, STATUS_OFFSET_PROBLEM = 700, STATUS_OFFSET_NA = 900, STATUS_ID_COMPLETE = 1000 };

enum HISTORY{ HST_DATE, HST_REQUEST_ID, HST_USER_EMAIL, HST_STAFF_ID, HST_STATUS, HST_DESCRIPTION };

enum USER_LIST{ USR_ACTIVATED, USR_EMAIL, USR_LAN_ID, USR_NAME, USR_COMPANY };

enum LINKS_LIST{ LINK_UID, LINK_SOURCE, LINK_URL };
enum SOURCE_LIST{ SOURCE_DATE, SOURCE_TITLE, SOURCE_URL };

enum STAFF_LEVEL{ STAFF_USER = 0, STAFF_EDITOR = 5, STAFF_ADMIN = 9 };

enum SORT_BY{ SORT_NORMAL, SORT_INVOICED };

enum MATERIAL{ MATERIAL_SCANNED, MATERIAL_ELECTRONIC_LICENSED, MATERIAL_ELECTRONIC_FREE, MATERIAL_ELECTRONIC_NOTFREE };

enum SEND_TYPE{ SEND_WEB, SEND_ATTACH, SEND_FTP, SEND_LINK };

enum INFORMATION_TYPE{ INFORMATION_LOIGN_PAGE, INFORMATION_NEWS_ITEM_MACRO };

#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif


